1. Field of the Invention
The invention relates to real-time instruction information tracing, and more particularly, to a method for recording instruction information of specific instructions executed by a microprocessor while the microprocessor runs a program.
2. Description of the Prior Art
In order to debug a program while a microprocessor runs the program, an instruction tracing technique is commonly used. The instruction tracing technique is used for tracing and recording instruction information of some specific instructions executed by the microprocessor while the microprocessor runs the program. The instruction information can be of various forms, such as a memory address storing the specific instruction or a controlling code of the specific instruction. What kind of instruction information that needs to be recorded depends on debugging demands.
Some bugs only occur when the microprocessor executes the whole program but does not occur if the running operation is interrupted. In other words, the bugs happen only when there are no interruptions caused by tracing operations when the microprocessor runs the whole program. In order to find this kind of bug, an instruction tracing method that can trace and record the specific instruction executed by the microprocessor without interrupting the running process of the microprocessor is often used.
Please refer to FIG. 1. FIG. 1 is a simple block diagram of the prior art and comprises a microprocessor 120 for running a program, a filter 130 electrically connected to the microprocessor 120 for filtering instruction information about the specific instructions from those instructions executed by the microprocessor 120, the filter 130 can be either hardware or software; a buffer 140 electrically connected to the filter 130 for recording the instruction information of the specific instructions executed by the microprocessor 120; an output interface 150 electrically connected to the buffer 140 for outputting the instruction information stored in the buffer 40; and a storage device 160 electrically connected to the output interface 150 for receiving the instruction information outputted from the output interface 150.
The prior art of FIG. 1 operates as follows. As the microprocessor 120 runs a program, a buffer 140 synchronously records instruction information about the specific instructions executed by the microprocessor 120. However, the capacity of the buffer 140 is often not capable recording the instruction information about every instruction in the entire program. Therefore, an output interface 150 is employed to transmit information already stored in the buffer 140 to the storage device 160. With the information transmitted, the buffer 140 has space to record new instruction information, meaning that the real-time instruction tracing is maintained.
One caveat remains though. The capacity of the buffer 140 and the transmitting speed of the output interface 150 need to be carefully matched to each other and the microprocessor 120. In other words, the capacity of the buffer 140 and the transmitting speed of the output interface 150 must both be large enough so that the buffer never becomes full. Otherwise, not all the information regarding the specific instructions executed by the microprocessor 120 will be recorded by the tracing operation for use in debugging.
Combining this requirement with the extremely fast operational speed of the microprocessor 120 necessitates the need for both the buffer 140 of corresponding capacity and the output interface 150 of corresponding transmitting speed. Meaning, the primary drawback of the prior art is that the buffer and output interface that fit the above conditions will result in increased hardware cost.